<?php
/** 
 * $Source: /cvsroot/pn-commerce/pn-commerce/pntemplates/plugins/function.pncStateDropdown.php,v $
 * $Author: landseer $
 * $Revision: 1.3 $
 * $Date: 2004/01/25 15:07:39 $
 *
 * Type: Function
 *
 * creates a <option></option> with all federal state / province names
 * @param: SelectedState - (optional) state name for preselection
 * @param: Format - (optional) 'long' or 'short' state names, default is short
 * @param: VariableName - name of the variable that will contain the selection 
 * @param: Country - name of the country, currently usa or canada only
 * @return string 
 */
function smarty_function_pncStateDropdown($params, &$smarty)
{
    extract( $params );
    if( !$VariableName )
    {  
         $smarty->trigger_error("*** error: missing parameter 'VariableName' ***");
    }
    if( !$Country )
    {  
        $smarty->trigger_error("*** error: missing parameter 'Country' ***");
    }
    if( ($Format) AND ( ( $Format <> 'long' ) AND ( $Format <> 'short' ) ) )
    {
        $smarty->trigger_error("*** error: wrong parameter $Format in 'Format' ***");
    }

    if( pnModAPILoad( 'pncommerce', 'user' ) )
    {
        return pnModAPIFunc( 'pncommerce', 'user', 'getFederalStateListForSelect',
                             array( 'VariableName'  => $VariableName,
                                    'SelectedState' => $SelectedState,
                                    'Format'        => $Format,
                                    'Country'       => $Country ) );
    }
    else
    {
        $smarty->trigger_error("Could not load userapi",USER_ERROR);
        return false;
    }
}
?>
